package com.qingzhuge.manager.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * @author : zero.xiao
 * @description : 数据过滤，切面处理类
 * @date :2018/6/8 0008 下午 15:25
 * @modified :
 * @since : 1.0.0
 */
@Slf4j
@Aspect
@Component
public class DataDeleteMenuAspect {

    @Pointcut("execution( * com.qingzhuge.resource.service.impl.SysResourceServiceImpl.deleteById(..))")
    public void record() {
    }


    @Around("record()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        log.debug("O AOP:删除菜单时，删除菜单与角色关联");
        Object result = point.proceed();
        Object params = point.getArgs()[0];
        if (params instanceof Serializable && (Boolean)result) {
            //删除菜单与角色关联
            log.debug("TODO AOP:删除菜单与角色关代码暂时注释");
        }
        return result;
    }
}
